# 
# Download Control code is copyright Kumar McMillan and contributors.
# It is dual licensed under:
#   Gnu Public License Version 3
#   Limited Commercial License
#
# See the following wiki page for details:
# http://code.google.com/p/downloadcontrol/wiki/AboutTheLicense
#

"""Utilities for working with Amazon S3."""

from django.conf import settings
import boto
UserAgent = 'DownloadControl'
default_bucket = settings.DOWNLOADCONTROL_S3_BUCKET

def get_authenticated_url(key, expires_in, bucket=default_bucket, method='GET', 
                            aws_access_key_id=None, aws_secret_access_key=None):
    conn = boto.connect_s3( aws_access_key_id=aws_access_key_id, 
                            aws_secret_access_key=aws_secret_access_key)
    return conn.generate_url(expires_in, method, bucket=bucket, key=key, query_auth=True)
